package com.bt.lms.ui.action.enp;

import com.bt.lms.ui.page.sys.style.BtnStyle;
import javafx.collections.ObservableList;
import javafx.event.ActionEvent;
import javafx.event.Event;
import javafx.event.EventHandler;
import javafx.geometry.Insets;
import javafx.geometry.Pos;
import javafx.scene.Node;
import javafx.scene.Scene;
import javafx.scene.control.*;
import javafx.scene.layout.HBox;
import javafx.scene.layout.VBox;
import javafx.scene.paint.Color;

/**
 * 编辑事件
 */
public class EditEnpPlanAction implements EventHandler {

    private VBox detailsVBox;
    private Integer width = 1280;
    private Integer height = 900;

    public EditEnpPlanAction(VBox detailsVBox) {
        this.detailsVBox = detailsVBox;

    }

    @Override
    public void handle(Event event) {
        VBox vBox = new VBox();


        //招生计划编号盒子
        HBox codeHBox = new HBox();
        codeHBox.setSpacing(20);
        codeHBox.setPadding(new Insets(15, 15, 15, 15));
        double codeHBoxHeight = height * 0.05;
        codeHBox.setPrefHeight(codeHBoxHeight);
        codeHBox.setPrefWidth(width);
        Label codeLb = new Label("招生计划编号*");
        codeLb.setPrefWidth(100);
        TextField codeTF = new TextField("666");
        codeTF.setId("codeTF");
        codeTF.setPromptText("请输入招生计划编号");
        codeHBox.getChildren().addAll(codeLb, codeTF);


        //计划名称盒子
        HBox nameHBox = new HBox();
        nameHBox.setSpacing(20);
        nameHBox.setPadding(new Insets(15, 15, 15, 15));
        double nameHBoxHeight = height * 0.05;
        nameHBox.setPrefHeight(nameHBoxHeight);
        nameHBox.setPrefWidth(width);
        Label nameLb = new Label("计划名称*");
        nameLb.setPrefWidth(100);
        TextField nameTf = new TextField("博添");
        nameTf.setId("nameTf");
        nameTf.setPromptText("请输入计划名称");
        nameHBox.getChildren().addAll(nameLb, nameTf);


        //计划内容盒子
        HBox contentHBox = new HBox();
        contentHBox.setSpacing(20);
        contentHBox.setPadding(new Insets(15, 15, 15, 15));
        double contentHBoxHeight = height * 0.1;
        contentHBox.setPrefHeight(contentHBoxHeight);
        contentHBox.setPrefWidth(width);
        Label contentLb = new Label("计划内容*");
        contentLb.setPrefWidth(100);
        TextArea contentTA = new TextArea("进击下一关");
        contentTA.setId("contentTA");
        contentTA.setMinHeight(100);
        contentTA.setPromptText("请输入内容");
        contentHBox.getChildren().addAll(contentLb, contentTA);


        //招生层次盒子
        HBox levelHBox = new HBox();
        levelHBox.setSpacing(20);
        levelHBox.setPadding(new Insets(15, 15, 15, 15));
        double levelHBoxHeight = height * 0.05;
        levelHBox.setPrefHeight(levelHBoxHeight);
        levelHBox.setPrefWidth(width);
        Label levelLb = new Label("招生层次*");
        levelLb.setPrefWidth(100);
        ComboBox<String> levelCom = new ComboBox<>();
        levelCom.getSelectionModel().select("不限");
        levelCom.getItems().add("高中");
        levelCom.getItems().add("大专");
        levelCom.getItems().add("其他");
        levelCom.setId("levelCom");
        levelHBox.getChildren().addAll(levelLb, levelCom);

        //招生专业盒子
        HBox specialtyHBox = new HBox();
        specialtyHBox.setSpacing(20);
        specialtyHBox.setPadding(new Insets(15, 15, 15, 15));
        double specialtyHBoxHeight = height * 0.05;
        specialtyHBox.setPrefHeight(specialtyHBoxHeight);
        specialtyHBox.setPrefWidth(width);

        Label specialtyLb = new Label("招生专业*");
        specialtyLb.setPrefWidth(100);
        ComboBox<String> specialtyCom = new ComboBox<>();
        specialtyCom.getSelectionModel().select("不限");
        specialtyCom.getItems().add("不限");
        specialtyCom.setId("specialtyCom");
        specialtyHBox.getChildren().addAll(specialtyLb, specialtyCom);


        //招生人数盒子
        HBox enPopulationHBox = new HBox();
        enPopulationHBox.setSpacing(20);
        enPopulationHBox.setPadding(new Insets(15, 15, 15, 15));
        double enPopulationHBoxHeight = height * 0.05;
        enPopulationHBox.setPrefHeight(enPopulationHBoxHeight);
        enPopulationHBox.setPrefWidth(width);
        Label enPopulationLb = new Label("招生人数*");
        enPopulationLb.setPrefWidth(100);
        TextField enPopulationTF = new TextField("66");
        enPopulationTF.setPromptText("请输入招生人数");
        enPopulationTF.setId("enPopulationTF");
        enPopulationHBox.getChildren().addAll(enPopulationLb, enPopulationTF);

        //学习中心盒子
        HBox studyCentreHBox = new HBox();
        studyCentreHBox.setSpacing(20);
        studyCentreHBox.setPadding(new Insets(15, 15, 15, 15));
        double studyCentreHBoxHeight = height * 0.05;
        studyCentreHBox.setPrefHeight(studyCentreHBoxHeight);
        studyCentreHBox.setPrefWidth(width);
        Label studyCentreLb = new Label("学习中心");
        studyCentreLb.setPrefWidth(100);
        Button studyCentreBtn = new Button("选择学习中心");
        studyCentreBtn.setStyle("-fx-background-color: #00a6ff");
        studyCentreHBox.getChildren().addAll(studyCentreLb, studyCentreBtn);


        //关联教学计划盒子
        HBox associationItemsHBox = new HBox();
        associationItemsHBox.setSpacing(20);
        associationItemsHBox.setPadding(new Insets(15, 15, 15, 15));
        double associationItemsHBoxHeight = height * 0.05;
        associationItemsHBox.setPrefHeight(associationItemsHBoxHeight);
        associationItemsHBox.setPrefWidth(width);
        Label associationItemsLb = new Label("关联教学计划");
        associationItemsLb.setPrefWidth(100);
        Button teachingPlanBtn = new Button("选择教学计划");
        teachingPlanBtn.setStyle("-fx-background-color: #00a6ff");
        associationItemsHBox.getChildren().addAll(associationItemsLb, teachingPlanBtn);



        //学费标准盒子
        HBox tuitionHBox = new HBox();
        tuitionHBox.setSpacing(20);
        tuitionHBox.setPadding(new Insets(15, 15, 15, 15));
        double tuitionHBoxHeight = height * 0.05;
        tuitionHBox.setPrefHeight(tuitionHBoxHeight);
        tuitionHBox.setPrefWidth(width);
        Label tuitionLb = new Label("学费标准*");
        tuitionLb.setPrefWidth(100);
        TextField tuitionTf = new TextField("5000");
        tuitionTf.setPromptText("请输入学费");
        tuitionTf.setId("tuitionTf");
        ComboBox<String> tuitionCom = new ComboBox<>();
        tuitionCom.setId("tuitionCom");
        tuitionCom.getSelectionModel().select("元/学年");
        tuitionCom.getItems().add("元/学年");
        tuitionCom.getItems().add("元/学分");
        tuitionCom.getItems().add("元/学时");
        tuitionHBox.getChildren().addAll(tuitionLb, tuitionTf, tuitionCom);

        //报名起止时间盒子
        HBox timeHBox = new HBox();
        timeHBox.setSpacing(20);
        timeHBox.setPadding(new Insets(15, 15, 15, 15));
        double timeHBoxHeight = height * 0.05;
        timeHBox.setPrefHeight(timeHBoxHeight);
        timeHBox.setPrefWidth(width);
        Label timeLb = new Label("报名起止时间*");
        timeLb.setPrefWidth(100);
        DatePicker startTimeDp = new DatePicker();
        startTimeDp.setId("startTimeDp");
        Label label = new Label("至");
        DatePicker stopTimeDp = new DatePicker();
        stopTimeDp.setId("stopTimeDp");
        timeHBox.getChildren().addAll(timeLb, startTimeDp, label, stopTimeDp);


        //报名方式
        HBox regModeHBox = new HBox();
        regModeHBox.setSpacing(20);
        regModeHBox.setPadding(new Insets(15,15,15,15));
        double regModeHBoxHeight=height*0.05;
        regModeHBox.setPrefHeight(regModeHBoxHeight);
        regModeHBox.setPrefWidth(width);
        Label regModeLab = new Label("报名方式");
        regModeLab.setPrefWidth(100);
        ComboBox<Object> regModeCom = new ComboBox<>();
        regModeCom.getSelectionModel().select("线上");
        regModeCom.setId("regModeCom");
        regModeCom.getItems().add("线下");
        regModeCom.getItems().add("都可以");
        regModeHBox.getChildren().addAll(regModeLab,regModeCom);


        //报名地点盒子
        HBox enrollmentLocationHBox = new HBox();
        enrollmentLocationHBox.setSpacing(20);
        enrollmentLocationHBox.setPadding(new Insets(15, 15, 15, 15));
        double enrollmentLocationHBoxHeight = height * 0.05;
        enrollmentLocationHBox.setPrefHeight(enrollmentLocationHBoxHeight);
        enrollmentLocationHBox.setPrefWidth(width);
        Label enrollmentLocationLb = new Label("报名地点*");
        enrollmentLocationLb.setPrefWidth(100);
        ComboBox<String> enpLocationCom = new ComboBox<>();
        enpLocationCom.setId("enpLocationCom");
        enpLocationCom.getSelectionModel().select("北京市");
        enpLocationCom.getItems().add("北京市");
        ComboBox<String> areaCom = new ComboBox<>();
        areaCom.setId("areaCom");
        areaCom.getSelectionModel().select("海淀区");
        areaCom.getItems().add("海淀区");
        TextField enrollmentLocationTF = new TextField("济南");
        enrollmentLocationTF.setPromptText("请输入您的详细地址");
        enrollmentLocationTF.setId("enrollmentLocationTF");
        enrollmentLocationHBox.getChildren().addAll(enrollmentLocationLb, enpLocationCom, areaCom, enrollmentLocationTF);

        //联系人盒子
        HBox LtdContactHBox = new HBox();
        LtdContactHBox.setSpacing(20);
        LtdContactHBox.setPadding(new Insets(15, 15, 15, 15));
        double LtdContactHBoxHeight = height * 0.05;
        LtdContactHBox.setPrefHeight(LtdContactHBoxHeight);
        LtdContactHBox.setPrefWidth(width);
        Label ltdContactLb = new Label("联系人*");
        ltdContactLb.setPrefWidth(100);
        TextField ltdContactTF = new TextField("博添");
        ltdContactTF.setPromptText("请输入联系人");
        ltdContactTF.setId("ltdContactTF");
        LtdContactHBox.getChildren().addAll(ltdContactLb, ltdContactTF);

        //移动电话盒子
        HBox phoneHBox = new HBox();
        phoneHBox.setSpacing(20);
        phoneHBox.setPadding(new Insets(15, 15, 15, 15));
        double phoneHBoxHeight = height * 0.05;
        phoneHBox.setPrefHeight(phoneHBoxHeight);
        phoneHBox.setPrefWidth(width);
        Label phoneLb = new Label("电话*");
        phoneLb.setPrefWidth(100);
        TextField phoneTF = new TextField("12345678910");
        phoneTF.setPromptText("请输入你的电话号码");
        phoneTF.setId("phoneTF");
        phoneHBox.getChildren().addAll(phoneLb, phoneTF);

        //电子邮箱
        HBox emailHBox = new HBox();
        emailHBox.setSpacing(20);
        emailHBox.setPadding(new Insets(15, 15, 15, 15));
        double emailHBoxHeight = height * 0.05;
        emailHBox.setPrefHeight(emailHBoxHeight);
        emailHBox.setPrefWidth(width);
        Label emailLb = new Label("电子邮箱*");
        emailLb.setPrefWidth(100);
        TextField emailTF = new TextField("2920081635@qq.com");
        emailTF.setPromptText("请输入电子邮箱");
        emailTF.setId("emailTF");
        emailHBox.getChildren().addAll(emailLb, emailTF);

        //大盒子
        HBox totalHBox = new HBox();
        totalHBox.setSpacing(20);
        totalHBox.setPadding(new Insets(15, 15, 15, 15));
        double totalHBoxHeight = height * 0.1;
        totalHBox.setPrefHeight(totalHBoxHeight);
        totalHBox.setPrefWidth(width);
        //报名材料标签盒子
        HBox materialsHBox = new HBox();
        materialsHBox.setSpacing(20);
        double materialsHBoxHeight = height * 0.1;
        materialsHBox.setMinWidth(materialsHBoxHeight);
        materialsHBox.setMinWidth(width * 0.05);
        Label materialsLb = new Label("报名材料*");
        materialsLb.setPrefWidth(100);
        materialsHBox.getChildren().add(materialsLb);
        totalHBox.getChildren().add(materialsHBox);

        //招生材料类型盒子
        VBox dataHBox = new VBox();
        dataHBox.setId("dataHBox");
        dataHBox.setSpacing(20);
        //dataHBox.setPadding(new Insets(15,15,15,15));
        double dataHBoxHeight = height * 0.05;
        dataHBox.setPrefHeight(dataHBoxHeight);
        dataHBox.setPrefWidth(width * 0.25);
        CheckBox idBox = new CheckBox("身份证");
        idBox.setId("idBox");
        CheckBox picBox = new CheckBox("照片");
        picBox.setId("picBox");
        CheckBox diplomaBox = new CheckBox("学历证明");
        diplomaBox.setId("diplomaBox");
        CheckBox degreeBox = new CheckBox("学位证明");
        degreeBox.setId("degreeBox");
        CheckBox bodyExaBox = new CheckBox("体检报告");
        bodyExaBox.setId("bodyExaBox");
        CheckBox restsBox = new CheckBox("其他");
        restsBox.setId("restsBox");

        dataHBox.getChildren().addAll(idBox, picBox, diplomaBox, degreeBox, bodyExaBox, restsBox);
        totalHBox.getChildren().add(dataHBox);


        //报名事项盒子
        HBox itemsHBox = new HBox();
        itemsHBox.setSpacing(20);
        itemsHBox.setPadding(new Insets(15,15,15,15));
        double itemsHBoxHeight=height*0.1;
        itemsHBox.setPrefHeight(itemsHBoxHeight);
        itemsHBox.setPrefWidth(width);
        Label itemsLb = new Label("报名事项");
        itemsLb.setPrefWidth(100);
        TextArea itemsTA = new TextArea("上进行数据采集");
        itemsTA.setMinHeight(100);
        itemsTA.setPromptText("请输入报名事项");
        itemsTA.setId("itemsTA");
        itemsHBox.getChildren().addAll(itemsLb,itemsTA);

        //毕/结业相关事项盒子
        HBox graduateHBox = new HBox();
        graduateHBox.setSpacing(20);
        graduateHBox.setPadding(new Insets(15, 15, 15, 15));
        double graduateHBoxHeight = height * 0.1;
        graduateHBox.setPrefHeight(graduateHBoxHeight);
        graduateHBox.setPrefWidth(width);
        Label graduateLb = new Label("毕/结业相关事项");
        graduateLb.setPrefWidth(100);
        TextArea graduateTA = new TextArea("仅仅是创建时间");
        graduateTA.setMinHeight(100);
        graduateTA.setPromptText("请输入毕/结业相关事项");
        graduateTA.setId("graduateTA");
        graduateHBox.getChildren().addAll(graduateLb, graduateTA);

        //补充说明盒子
        HBox replenishHBox = new HBox();
        replenishHBox.setSpacing(20);
        replenishHBox.setPadding(new Insets(15, 15, 15, 15));
        double replenishHBoxHeight = height * 0.1;
        replenishHBox.setPrefHeight(replenishHBoxHeight);
        replenishHBox.setPrefWidth(width);
        Label replenishLb = new Label("补充说明");
        replenishLb.setPrefWidth(100);
        TextArea replenishTA = new TextArea("菜市场采石场");
        replenishTA.setMinHeight(100);
        replenishTA.setPromptText("请输入补充说明");
        replenishTA.setId("replenishTA");
        replenishHBox.getChildren().addAll(replenishLb, replenishTA);

        //保存取消按钮盒子
        HBox saveHBox = new HBox();
        saveHBox.setAlignment(Pos.CENTER);
        saveHBox.setSpacing(20);
        saveHBox.setPadding(new Insets(15, 15, 15, 15));
        double saveHBoxHeight = height * 0.1;
        saveHBox.setPrefHeight(saveHBoxHeight);
        saveHBox.setPrefWidth(width);
        Button saveBtn = new Button("保存");
        BtnStyle.saveBtn(saveBtn);
        BtnStyle.saveBtnAction(saveBtn);
        saveBtn.setPrefWidth(100);
        saveBtn.setStyle("-fx-background-color: #3e73d5");
        Button cancelBtn = new Button("取消");
        BtnStyle.cancelBtn(cancelBtn);
        BtnStyle.cancelBtnAction(cancelBtn);
        cancelBtn.setPrefWidth(100);
        cancelBtn.setStyle("-fx-background-color: #d73359");
        saveHBox.getChildren().addAll(saveBtn, cancelBtn);

        //编辑招生计划取消按钮事件
        EditEnpPlanCancelAction editEnpPlanCancelAction = new EditEnpPlanCancelAction();
        cancelBtn.setOnAction(editEnpPlanCancelAction);

        //保存编辑招生计划按钮事件
        SaveEditEnpPlanBtnAction saveEditEnpPlanBtnAction = new SaveEditEnpPlanBtnAction(vBox);
        saveBtn.setOnAction(saveEditEnpPlanBtnAction);




        vBox.getChildren().addAll(codeHBox, nameHBox, contentHBox, levelHBox, specialtyHBox, enPopulationHBox, studyCentreHBox, associationItemsHBox, tuitionHBox, timeHBox, regModeHBox, enrollmentLocationHBox, LtdContactHBox, phoneHBox, emailHBox, totalHBox, itemsHBox, graduateHBox, replenishHBox, saveHBox);

        ObservableList<Node> children = detailsVBox.getChildren();//获取孩子
        children.remove(0);
        children.set(0, vBox);

    }
}

